<?php
namespace app\app\controller\v1;
use think\Request;
use think\Controller;
use app\app\util\OnlineUtils;

class BaseController extends Controller{

	public function _initialize()
	{
        header("Access-Control-Allow-Origin: * ");
        header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
        $request = Request::instance();
        $header = $request->header();
        $accessActionArr = array('login','test','resetFreeNumber','taskList','blockRank','notifyUrl');
		
        if($request->isOptions()){
            echo '{"code":200,"message":"options","data":""}';
            die(0);
        }
         if(in_array($request->action(),$accessActionArr)){

         }else{
             if(!empty($header['token'])){
                 if(OnlineUtils::requestIsLogin()){

                 }else{
                     header( 'content-type: application/json; charset=utf-8');
                     echo '{"code":500,"message":"未登录","data":""}';
                     die(0);
                 }
             }else{
                 header( 'content-type: application/json; charset=utf-8');
                 echo '{"code":500,"message":"not access","data":""}';
                 die(0);
             }
         }
	}
	
}